function TableBar(handler) {
    var bar = {
        init: function () {
            this._initView();
        },

        addTabs: function (tabs) {
            if (!$.isArray(tabs) || tabs.length <= 1) {
                $(".tablebar").hide();
                return;
            }
            $(".tablebar").show();

            var select = "";
            var html = "";
            $(tabs).each(function (i, v) {
                var id = "tab_" + (v.key + "").split(".").join("_") + "_" + (v.value + "").split(".").join("_");
                if (i == 0) {
                    select = "#" + id;
                }
                html += "<span id='" + id + "' class='margin-h5 table_tab' " +
                    "ng-click=\"onAction('" + v.key + "', '" + v.value + "')\">" + v.title + "</span>";
            });

            var scope = $("body").scope();
            var el = scope.compile(html)(scope);
            $(".table-barleft").html(el);
            this._current = select;
            $(this._current).addClass("table_tab_select");
        },

        _initView: function () {
            var scope = $("body").scope();

            var html = "<div class=\"table-barleft pull-left\"></div>" +
                "<div class=\"pull-right\">" +
                "<span>" +
                "<i class=\"fa fa-print hide\"></i>" +
                "<a style='cursor: hand' class='hide' ng-click=\"onAction('print')\">打印</a>" +
                "</span>&nbsp;&nbsp;" +
                "<span>" +
                "<i class=\"fa fa-download hide\"></i>" +
                "<a style='cursor: hand' class='hide' ng-click=\"onAction('download')\">下载</a>" +
                "</span>" +
                "</div>";

            var el = scope.compile(html)(scope);
            $(".tablebar").html(el);

            scope.safeApply(function () {
                scope.onAction = function (key, value) {
                    var c = "#tab_" + (key + "").split(".").join("_") + "_" + (value + "").split(".").join("_");
                    if (this._current != c) {
                        this._tableBarHander(key, value);
                    }
                    if (this._current) {
                        $(this._current).removeClass("table_tab_select");
                    }
                    this._current = c;
                    $(this._current).addClass("table_tab_select");
                }.bind(this);
            }.bind(this));
        }
    };
    bar.init();
    bar._tableBarHander = handler;
    return bar;
};